home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CDsupport / ClassAct / Examples / Speed / SpeedExample3.c < prev    next >
C/C++ Source or Header  |  1997-04-27  |  11KB  |  445 lines

  1. /* ClassAct Example
  2.  * Copyright © 1995 Christopher Aldi
  3.  * All Rights Reserved.
  4.  *
  5.  * This Example Shows ClassAct's speed laying out & rendering 50 palettes
  6.  */
  7.  
  8. #include <clib/macros.h>
  9. #include <clib/alib_protos.h>
  10.  
  11. #include <proto/exec.h>
  12. #include <proto/dos.h>
  13. #include <proto/utility.h>
  14. #include <proto/graphics.h>
  15. #include <proto/intuition.h>
  16.  
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20.  
  21. #include <proto/window.h>
  22. #include <classes/window.h>
  23.  
  24. #include <libraries/gadtools.h>
  25. #include <classact.h>
  26. #include <classact_author.h>
  27.  
  28. struct ClassLibrary *WindowBase;
  29. struct ClassLibrary *LayoutBase;
  30. struct ClassLibrary *PaletteBase;
  31.  
  32. LONG ARG[1];
  33.  
  34. int main( void )
  35. {
  36.     struct Window *window;
  37.     Object *Win_Object;
  38.     ULONG signal, result;
  39.     ULONG done = FALSE;
  40.     struct RDArgs *args;
  41.     
  42.     if (!(args = ReadArgs("ND=NODEFER/S",ARG,NULL)))
  43.         return 20;
  44.  
  45.     /* Open the classes we will use. Note, classlib.lib SAS/C or DICE autoinit
  46.      * can do this for you automatically.
  47.      */
  48.     if( WindowBase = (struct ClassLibrary *)OpenLibrary("window.class",0L) )
  49.     {
  50.         if( LayoutBase = (struct ClassLibrary *)OpenLibrary("gadgets/layout.gadget",0L) )
  51.         {
  52.             if( PaletteBase = (struct ClassLibrary *)OpenLibrary("gadgets/palette.gadget",0L) )
  53.             {
  54.                 /* Create the window object.
  55.                  */
  56.                 Win_Object = WindowObject,
  57.                     WA_ScreenTitle, "ClassAct Copyright 1995, Phantom Development LLC.",
  58.                     WA_Title, "SpeedTest2 (50 palettes)",
  59.                     WA_SizeGadget, TRUE,
  60.                     WA_Left, 40,
  61.                     WA_Top, 30,
  62.                     WA_DepthGadget, TRUE,
  63.                     WA_DragBar, TRUE,
  64.                     WA_CloseGadget, TRUE,
  65.                     WA_Activate, TRUE,
  66.                     WINDOW_ParentGroup, HGroupObject,
  67.                         TAligned, 
  68.                         LAYOUT_SpaceOuter, TRUE,
  69.                         LAYOUT_DeferLayout, !ARG[0],
  70.                         StartVGroup,
  71.                             StartMember, PaletteObject,
  72.                                 PALETTE_NumColors, 8,
  73.                                 PALETTE_Color, 1,
  74.                             EndMember,
  75.                             CHILD_MinWidth, 50,
  76.                             CHILD_MinHeight, 15,
  77.                             StartMember, PaletteObject,
  78.                                 PALETTE_NumColors, 8,
  79.                                 PALETTE_Color, 1,
  80.                             EndMember,
  81.                             CHILD_MinWidth, 50,
  82.                             CHILD_MinHeight, 15,
  83.                             StartMember, PaletteObject,
  84.                                 PALETTE_NumColors, 8,
  85.                                 PALETTE_Color, 1,
  86.                             EndMember,
  87.                             CHILD_MinWidth, 50,
  88.                             CHILD_MinHeight, 15,
  89.                             StartMember, PaletteObject,
  90.                                 PALETTE_NumColors, 8,
  91.                                 PALETTE_Color, 1,
  92.                             EndMember,
  93.                             CHILD_MinWidth, 50,
  94.                             CHILD_MinHeight, 15,
  95.                             StartMember, PaletteObject,
  96.                                 PALETTE_NumColors, 8,
  97.                                 PALETTE_Color, 1,
  98.                             EndMember,
  99.                             CHILD_MinWidth, 50,
  100.                             CHILD_MinHeight, 15,
  101.                             StartMember, PaletteObject,
  102.                                 PALETTE_NumColors, 8,
  103.                                 PALETTE_Color, 1,
  104.                             EndMember,
  105.                             CHILD_MinWidth, 50,
  106.                             CHILD_MinHeight, 15,
  107.                             StartMember, PaletteObject,
  108.                                 PALETTE_NumColors, 8,
  109.                                 PALETTE_Color, 1,
  110.                             EndMember,
  111.                             CHILD_MinWidth, 50,
  112.                             CHILD_MinHeight, 15,
  113.                             StartMember, PaletteObject,
  114.                                 PALETTE_NumColors, 8,
  115.                                 PALETTE_Color, 1,
  116.                             EndMember,
  117.                             CHILD_MinWidth, 50,
  118.                             CHILD_MinHeight, 15,
  119.                             StartMember, PaletteObject,
  120.                                 PALETTE_NumColors, 8,
  121.                                 PALETTE_Color, 1,
  122.                             EndMember,
  123.                             CHILD_MinWidth, 50,
  124.                             CHILD_MinHeight, 15,
  125.                             StartMember, PaletteObject,
  126.                                 PALETTE_NumColors, 8,
  127.                                 PALETTE_Color, 1,
  128.                             EndMember,
  129.                             CHILD_MinWidth, 50,
  130.                             CHILD_MinHeight, 15,
  131.                         End,
  132.                         StartVGroup,
  133.                             StartMember, PaletteObject,
  134.                                 PALETTE_NumColors, 8,
  135.                                 PALETTE_Color, 1,
  136.                             EndMember,
  137.                             CHILD_MinWidth, 50,
  138.                             CHILD_MinHeight, 15,
  139.                             StartMember, PaletteObject,
  140.                                 PALETTE_NumColors, 8,
  141.                                 PALETTE_Color, 1,
  142.                             EndMember,
  143.                             CHILD_MinWidth, 50,
  144.                             CHILD_MinHeight, 15,
  145.                             StartMember, PaletteObject,
  146.                                 PALETTE_NumColors, 8,
  147.                                 PALETTE_Color, 1,
  148.                             EndMember,
  149.                             CHILD_MinWidth, 50,
  150.                             CHILD_MinHeight, 15,
  151.                             StartMember, PaletteObject,
  152.                                 PALETTE_NumColors, 8,
  153.                                 PALETTE_Color, 1,
  154.                             EndMember,
  155.                             CHILD_MinWidth, 50,
  156.                             CHILD_MinHeight, 15,
  157.                             StartMember, PaletteObject,
  158.                                 PALETTE_NumColors, 8,
  159.                                 PALETTE_Color, 1,
  160.                             EndMember,
  161.                             CHILD_MinWidth, 50,
  162.                             CHILD_MinHeight, 15,
  163.                             StartMember, PaletteObject,
  164.                                 PALETTE_NumColors, 8,
  165.                                 PALETTE_Color, 1,
  166.                             EndMember,
  167.                             CHILD_MinWidth, 50,
  168.                             CHILD_MinHeight, 15,
  169.                             StartMember, PaletteObject,
  170.                                 PALETTE_NumColors, 8,
  171.                                 PALETTE_Color, 1,
  172.                             EndMember,
  173.                             CHILD_MinWidth, 50,
  174.                             CHILD_MinHeight, 15,
  175.                             StartMember, PaletteObject,
  176.                                 PALETTE_NumColors, 8,
  177.                                 PALETTE_Color, 1,
  178.                             EndMember,
  179.                             CHILD_MinWidth, 50,
  180.                             CHILD_MinHeight, 15,
  181.                             StartMember, PaletteObject,
  182.                                 PALETTE_NumColors, 8,
  183.                                 PALETTE_Color, 1,
  184.                             EndMember,
  185.                             CHILD_MinWidth, 50,
  186.                             CHILD_MinHeight, 15,
  187.                             StartMember, PaletteObject,
  188.                                 PALETTE_NumColors, 8,
  189.                                 PALETTE_Color, 1,
  190.                             EndMember,
  191.                             CHILD_MinWidth, 50,
  192.                             CHILD_MinHeight, 15,
  193.                         End,
  194.                         StartVGroup,
  195.                             StartMember, PaletteObject,
  196.                                 PALETTE_NumColors, 8,
  197.                                 PALETTE_Color, 1,
  198.                             EndMember,
  199.                             CHILD_MinWidth, 50,
  200.                             CHILD_MinHeight, 15,
  201.                             StartMember, PaletteObject,
  202.                                 PALETTE_NumColors, 8,
  203.                                 PALETTE_Color, 1,
  204.                             EndMember,
  205.                             CHILD_MinWidth, 50,
  206.                             CHILD_MinHeight, 15,
  207.                             StartMember, PaletteObject,
  208.                                 PALETTE_NumColors, 8,
  209.                                 PALETTE_Color, 1,
  210.                             EndMember,
  211.                             CHILD_MinWidth, 50,
  212.                             CHILD_MinHeight, 15,
  213.                             StartMember, PaletteObject,
  214.                                 PALETTE_NumColors, 8,
  215.                                 PALETTE_Color, 1,
  216.                             EndMember,
  217.                             CHILD_MinWidth, 50,
  218.                             CHILD_MinHeight, 15,
  219.                             StartMember, PaletteObject,
  220.                                 PALETTE_NumColors, 8,
  221.                                 PALETTE_Color, 1,
  222.                             EndMember,
  223.                             CHILD_MinWidth, 50,
  224.                             CHILD_MinHeight, 15,
  225.                             StartMember, PaletteObject,
  226.                                 PALETTE_NumColors, 8,
  227.                                 PALETTE_Color, 1,
  228.                             EndMember,
  229.                             CHILD_MinWidth, 50,
  230.                             CHILD_MinHeight, 15,
  231.                             StartMember, PaletteObject,
  232.                                 PALETTE_NumColors, 8,
  233.                                 PALETTE_Color, 1,
  234.                             EndMember,
  235.                             CHILD_MinWidth, 50,
  236.                             CHILD_MinHeight, 15,
  237.                             StartMember, PaletteObject,
  238.                                 PALETTE_NumColors, 8,
  239.                                 PALETTE_Color, 1,
  240.                             EndMember,
  241.                             CHILD_MinWidth, 50,
  242.                             CHILD_MinHeight, 15,
  243.                             StartMember, PaletteObject,
  244.                                 PALETTE_NumColors, 8,
  245.                                 PALETTE_Color, 1,
  246.                             EndMember,
  247.                             CHILD_MinWidth, 50,
  248.                             CHILD_MinHeight, 15,
  249.                             StartMember, PaletteObject,
  250.                                 PALETTE_NumColors, 8,
  251.                                 PALETTE_Color, 1,
  252.                             EndMember,
  253.                             CHILD_MinWidth, 50,
  254.                             CHILD_MinHeight, 15,
  255.                         End,
  256.                         StartVGroup,
  257.                             StartMember, PaletteObject,
  258.                                 PALETTE_NumColors, 8,
  259.                                 PALETTE_Color, 1,
  260.                             EndMember,
  261.                             CHILD_MinWidth, 50,
  262.                             CHILD_MinHeight, 15,
  263.                             StartMember, PaletteObject,
  264.                                 PALETTE_NumColors, 8,
  265.                                 PALETTE_Color, 1,
  266.                             EndMember,
  267.                             CHILD_MinWidth, 50,
  268.                             CHILD_MinHeight, 15,
  269.                             StartMember, PaletteObject,
  270.                                 PALETTE_NumColors, 8,
  271.                                 PALETTE_Color, 1,
  272.                             EndMember,
  273.                             CHILD_MinWidth, 50,
  274.                             CHILD_MinHeight, 15,
  275.                             StartMember, PaletteObject,
  276.                                 PALETTE_NumColors, 8,
  277.                                 PALETTE_Color, 1,
  278.                             EndMember,
  279.                             CHILD_MinWidth, 50,
  280.                             CHILD_MinHeight, 15,
  281.                             StartMember, PaletteObject,
  282.                                 PALETTE_NumColors, 8,
  283.                                 PALETTE_Color, 1,
  284.                             EndMember,
  285.                             CHILD_MinWidth, 50,
  286.                             CHILD_MinHeight, 15,
  287.                             StartMember, PaletteObject,
  288.                                 PALETTE_NumColors, 8,
  289.                                 PALETTE_Color, 1,
  290.                             EndMember,
  291.                             CHILD_MinWidth, 50,
  292.                             CHILD_MinHeight, 15,
  293.                             StartMember, PaletteObject,
  294.                                 PALETTE_NumColors, 8,
  295.                                 PALETTE_Color, 1,
  296.                             EndMember,
  297.                             CHILD_MinWidth, 50,
  298.                             CHILD_MinHeight, 15,
  299.                             StartMember, PaletteObject,
  300.                                 PALETTE_NumColors, 8,
  301.                                 PALETTE_Color, 1,
  302.                             EndMember,
  303.                             CHILD_MinWidth, 50,
  304.                             CHILD_MinHeight, 15,
  305.                             StartMember, PaletteObject,
  306.                                 PALETTE_NumColors, 8,
  307.                                 PALETTE_Color, 1,
  308.                             EndMember,
  309.                             CHILD_MinWidth, 50,
  310.                             CHILD_MinHeight, 15,
  311.                             StartMember, PaletteObject,
  312.                                 PALETTE_NumColors, 8,
  313.                                 PALETTE_Color, 1,
  314.                             EndMember,
  315.                             CHILD_MinWidth, 50,
  316.                             CHILD_MinHeight, 15,
  317.                         End,
  318.                         StartVGroup,
  319.                             StartMember, PaletteObject,
  320.                                 PALETTE_NumColors, 8,
  321.                                 PALETTE_Color, 1,
  322.                             EndMember,
  323.                             CHILD_MinWidth, 50,
  324.                             CHILD_MinHeight, 15,
  325.                             StartMember, PaletteObject,
  326.                                 PALETTE_NumColors, 8,
  327.                                 PALETTE_Color, 1,
  328.                             EndMember,
  329.                             CHILD_MinWidth, 50,
  330.                             CHILD_MinHeight, 15,
  331.                             StartMember, PaletteObject,
  332.                                 PALETTE_NumColors, 8,
  333.                                 PALETTE_Color, 1,
  334.                             EndMember,
  335.                             CHILD_MinWidth, 50,
  336.                             CHILD_MinHeight, 15,
  337.                             StartMember, PaletteObject,
  338.                                 PALETTE_NumColors, 8,
  339.                                 PALETTE_Color, 1,
  340.                             EndMember,
  341.                             CHILD_MinWidth, 50,
  342.                             CHILD_MinHeight, 15,
  343.                             StartMember, PaletteObject,
  344.                                 PALETTE_NumColors, 8,
  345.                                 PALETTE_Color, 1,
  346.                             EndMember,
  347.                             CHILD_MinWidth, 50,
  348.                             CHILD_MinHeight, 15,
  349.                             StartMember, PaletteObject,
  350.                                 PALETTE_NumColors, 8,
  351.                                 PALETTE_Color, 1,
  352.                             EndMember,
  353.                             CHILD_MinWidth, 50,
  354.                             CHILD_MinHeight, 15,
  355.                             StartMember, PaletteObject,
  356.                                 PALETTE_NumColors, 8,
  357.                                 PALETTE_Color, 1,
  358.                             EndMember,
  359.                             CHILD_MinWidth, 50,
  360.                             CHILD_MinHeight, 15,
  361.                             StartMember, PaletteObject,
  362.                                 PALETTE_NumColors, 8,
  363.                                 PALETTE_Color, 1,
  364.                             EndMember,
  365.                             CHILD_MinWidth, 50,
  366.                             CHILD_MinHeight, 15,
  367.                             StartMember, PaletteObject,
  368.                                 PALETTE_NumColors, 8,
  369.                                 PALETTE_Color, 1,
  370.                             EndMember,
  371.                             CHILD_MinWidth, 50,
  372.                             CHILD_MinHeight, 15,
  373.                             StartMember, PaletteObject,
  374.                                 PALETTE_NumColors, 8,
  375.                                 PALETTE_Color, 1,
  376.                             EndMember,
  377.                             CHILD_MinWidth, 50,
  378.                             CHILD_MinHeight, 15,
  379.                         End,
  380.  
  381.                     EndMember,
  382.                 EndWindow;
  383.  
  384.                 /*  Object creation sucessful?
  385.                  */
  386.                 if( Win_Object )
  387.                 {
  388.                     /*  Open the window.
  389.                      */
  390.                     if( window = (struct Window *) CA_OpenWindow(Win_Object) )
  391.                     {
  392.                         ULONG wait;
  393.                         
  394.                         /* Obtain the window wait signal mask.
  395.                          */
  396.                         GetAttr( WINDOW_SigMask, Win_Object, &signal );
  397.  
  398.                         /* Input Event Loop
  399.                          */
  400.                         while( !done )
  401.                         {
  402.                             wait = Wait(signal|SIGBREAKF_CTRL_C);
  403.                             
  404.                             if (wait & SIGBREAKF_CTRL_C) done = TRUE;
  405.                             else
  406.  
  407.                             while ((result = CA_HandleInput(Win_Object,NULL)) != WMHI_LASTMSG)
  408.                             {
  409.                                 switch(result)
  410.                                 {
  411.                                     case WMHI_CLOSEWINDOW:
  412.                                         done = TRUE;
  413.                                         break;
  414.                                 }
  415.                             }
  416.                         }
  417.                     }
  418.  
  419.                     /* Disposing of the window object will
  420.                      * also close the window if it is
  421.                      * already opened and it will dispose of
  422.                      * all objects attached to it.
  423.                      */
  424.                     DisposeObject( Win_Object );
  425.                 }
  426.             }
  427.         }
  428.     }
  429.  
  430.     /* Close the classes.
  431.      */
  432.     if (LayoutBase) CloseLibrary( (struct Library *)LayoutBase );
  433.     if (PaletteBase) CloseLibrary( (struct Library *)PaletteBase );
  434.     if (WindowBase) CloseLibrary( (struct Library *)WindowBase );
  435.     
  436.     FreeArgs(args);
  437. }
  438.  
  439. #ifdef _DCC
  440. int wbmain( struct WBStartup *wbs )
  441. {
  442.         return( main( 0, NULL ));
  443. }
  444. #endif
  445.